export class ApiResult {
  private timestamp: any = new Date();
  private code: number;
  private message: string;
  private data: any;
  private debugInfo: any;

  constructor(
    code = 0,
    message = '请求成功',
    data?: any,
    debugInfo: any = null,
  ) {
    this.data = data;
    this.code = code;
    this.message = message;
    this.debugInfo = debugInfo;
  }
  /**
   * 带消息的成功响应
   * @param message 消息体
   * @param data 数据
   */
  public static SUCCESS(data: any, code?: number, message?: string) {
    return new ApiResult(code, message, data);
  }
  /**
   * 带消息的错误响应
   * @param message 消息体
   * @param data 数据
   */
  public static ERROR(code: number, message: string) {
    return new ApiResult(code, message);
  }

  /**
   *
   * @param code 状态码
   * @param message 消息
   * @param data 数据
   */
  public static Error_Filter(
    code: number,
    message = '请求成功',
    data?: any,
    debugInfo?: any,
  ) {
    return new ApiResult(code, message, data, debugInfo);
  }
}
